<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <script src="/layui/layui.js"></script>
    <script src="/js/jquery/jquery-3.5.1.js"></script>
    <script src="/js/book/book.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/bookList.css">
    <title>longmiyu</title>

</head>
<body  >
<!--style="  background:#FFF;background:rgba(200, 100, 100, 0.5);"-->
<div class="layui-header" style="filter:alpha(opacity=50);background:#d8be5e40;width:100%;" >
    <ul class="layui-nav  layui-layout-right " style="filter:alpha(opacity=50);background:#d8be5e00;" >
        <li class="layui-nav-item layui-hide-xs">
            <a href="javascript:theme()"  style="color: red;" >背景设置</a>

        </li>

    </ul>
</div>
<div class="book-title  " id = "book-title"></div>

<div class="table-css" id="book_list">
</div>
<script type="text/javascript"  th:inline="javascript">
    var data = [[${data}]];
    console.log(data)
    $.ajax({
        type:"post",
        url:'/bookMagic/queryDetailBookList',
        data:data,
        dataType:"json",
        async:false,
        contentType : "application/json; charset=utf-8",
        success: function(res){
            var book = res.data;
            var zjList = book.zjList;
            var btitle = book.title;
            document.title = btitle.ruleBookName;
            var div="";
            div="<div class='table-css'> " +
            "<div class='maininfo'>" +
                "<div class='info'>" +
                    "<h1>"+btitle.ruleBookName+"</h1>" +
                    "<p>作者："+btitle.ruleBookAuthor+"</p>" +
                    "<p>状态："+btitle.ruleBookState+"<a  onclick='downBookFile("+data+")'>txt下载</a></p>"+
                    "<p>最后更新:"+btitle.ruleBookLastChapterDate+"</p>"+
                    "<p>最新章节: <a onclick='newChapterContextfowdard("+JSON.stringify(btitle)+")'>"+btitle.ruleBookLastChapter+"</a></p>"+
                "</div>" +
                "<div class='intro'>"+btitle.ruleBookIntroduce+"</div>"+

                "</div>"+
                    "<div class='sidebar'>" +
                        "<div class='fmimg'>" +
                         "<img src="+btitle.ruleBookCoverUrl+" onerror=\"javascript:this.src='/img/magic/nocover.jpg';this.onerror = null\" alt="+btitle.ruleBookName+" width='120' height='150'>" +
                        "</div>" +
                    "</div>"+
                "</div>"
            $("#book-title").append(div);

            var num = zjList.length/3;
            var dd="";
            for(var i = 0; i < zjList.length; i++ ){
                var detail =  zjList[i] ;
                var html = "aa";
                dd += "<dd>" +
                            "<a  onclick='chapterContextfowdard("+JSON.stringify(detail)+")' target='_blank'>"+detail.chapterName+"</a>" +
                    "</dd>"
            }
            var div="";
            div="<div class='chapter_list'> "+
                "<dl>" +
                "<dt class='b_list'>  "+'《'+btitle.ruleBookName+'》'+"</dt>" +dd+

                "</dl>"+
                "</div>"
            $("#book_list").append(div);
            $("#downLoad").on("click", function () {
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.msg(' '+bookName+'', {
                        //skin: 'layui-layer-molv',
                        shadeClose: true,
                        time:0,
                        title: false,
                        closeBtn: 0,
                        area: ['300px', '150px'],
                        btn: ['下载']

                    },  function(){
                        window.open("/book/downloadBook?bookCode="+bookCode+"&bookName="+bookName+"");
                    });

                });
            });
        }
    });
   function chapterContextfowdard(obj){
    forward("/forward/book/pageBook/readMagicBook",obj)
   }
    function newChapterContextfowdard(obj){
        obj.bookRule=obj.bookRuleSource;//规则来源
        obj.chapterSource=obj.ruleBookChapterUrl;//最新章节url
        obj.chapterName = obj.ruleBookLastChapter;//最新章节名称
        obj.chapterContext="";//最新章节内容
        forward("/forward/book/pageBook/readMagicBook",obj);
    }
    function downBookFile(obj){

        //墨绿深蓝风
        var layer;
        layui.use('element', function () {
            var element = layui.element;
            var layui_element = layui.element,
                layui_layer = layui.layer,
                layui_form = layui.form;
        });
        layui.use('layer', function () {
            layer = layui.layer;
            layer.msg('hello');
        });
      //  downLoadFile("/bookMagic/downloadBook/",obj)
    }
</script>

</body>
</html>